package com.foreknow.demo14;

public class ExceptionDemo5 {
    public static int haha(){
        try {
            System.out.println(5/0);
            System.out.println("执行了try");
            return 1;
        }catch (Exception e){
            System.out.println("执行了catch");
            return 2;//当发生异常的时候,程序回跳到catch块中,
                     // 在catch return前,在Java虚拟机会将finally中的代码放在return前执行
        }finally {
            System.out.println("执行了finally");
            return 3;
        }

    }

    public static void main(String[] args) {
       int num = ExceptionDemo5.haha();
        System.out.println(num);

    }
}
